﻿using UnityEditor;
using UnityEngine;

namespace Gdmec.Config
{
    public class GameConfig
    {
        public static string AssetFilePath { get { return Application.dataPath; } }
        public static string ProjectFilePath { get { return PathUtil.DirName(Application.dataPath); } }
        public static string AssetBundleFilePath
        {
            get
            {
#if UNITY_EDITOR
                if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
                {
                    return "AssetBundle/Android/StreamingAssets";
                }
#endif
                return "Assets/StreamingAssets";
            }
        }

        /// <summary>
        /// 脚本路径
        /// </summary>
        public static string LuaScriptPath 
        {
            get 
            {
                return "Lua/src";
            }
        }

        /// <summary>
        /// 热更目录
        /// </summary>
        public static string HotFixFilePath 
        {
            get 
            {
#if UNITY_EDITOR
                return ProjectFilePath + "/" + "HotFix";
#else
                return Application.persistentDataPath + "/" + "HotFix";
#endif
            }
        }

        /// <summary>
        /// 转换项目路径
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static string ToProjectPath(string path)
        {
            return ProjectFilePath + "/" + path;
        }

        /// <summary>
        /// 转流路径
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static string ToStreamingAssetPath(string path) 
        {
            return Application.streamingAssetsPath + "/" + path;
        }

        /// <summary>
        /// 转热更路径
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static string ToHotFixPath(string path) 
        {
            return HotFixFilePath + "/" + path;
        }
    }
}
